package com.usefullc.system.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.usefullc.common.user.OnlineUser;
import com.usefullc.common.user.OnlineUserManager;
import com.usefullc.system.domain.JobTemplate;
import com.usefullc.system.entity.WebResult;
import com.usefullc.system.query.DataDictQuery;
import com.usefullc.system.query.JobTemplateQuery;
import com.usefullc.system.service.DataDictService;
import com.usefullc.system.service.JobTemplateService;
import com.usefullc.system.service.component.ImgCodeComponent;
import com.usefullc.system.service.component.SmsComponent;
import com.usefullc.system.service.component.SystemConfigComponent;
import com.usefullc.system.validator.UsefulValid;
import com.usefullc.system.vo.TreeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Sampson
 * @date: 2022-03-19 12:02
 */
@RestController
@RequestMapping(path = "/system/anonymous/")
@Api(tags = "系统匿名访问模块")
public class SystemAnonymousController {

    @Autowired
    private ImgCodeComponent imgCodeComponent;

    @Autowired
    private SmsComponent smsComponent;

    @Autowired
    private JobTemplateService jobTemplateService;


    @Autowired
    private SystemConfigComponent systemConfigComponent;

    @Autowired
    private DataDictService dataDictService;



    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "定时任务模板所有列表", response = WebResult.class)
    @GetMapping(path = "jobTemplate/listAll", produces = "application/json")
    public WebResult listAll(@UsefulValid(query = true) JobTemplateQuery query) {
        List<JobTemplate> dataList = jobTemplateService.findAll(query);
        return WebResultBuilder.successResult(dataList);
    }

    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "获取树列表", response = WebResult.class)
    @GetMapping(path = "dataDict/listTree", produces = "application/json")
    public WebResult listTree(DataDictQuery query) {
        OnlineUser loginUser = OnlineUserManager.getLoginUser();
        query.setTenantId(loginUser.getTenantId());
        List<TreeVo> dataList = dataDictService.listTree(query);
        return WebResultBuilder.successResult(dataList);

    }







}
